package com.wuzhun.wxmp.service;

import com.wuzhun.wxmp.model.dto.OperateLogDTO;
import com.wuzhun.wxmp.model.entity.OperateLog;
import com.wuzhun.wxmp.util.DateTimeUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * 异步服务
 *
 * @author Paulin
 * @date 2023/6/13 17:36
 */
@Async
@Service
public class AsyncService {
    @Resource
    private IOperateLogService operateLogService;

    /**
     * 保存操作日志
     */
    public void insertOperateLog(OperateLogDTO operateLogDTO) {
        OperateLog operateLog = new OperateLog();
        BeanUtils.copyProperties(operateLogDTO, operateLog);
        operateLog.setRequestDate(DateTimeUtil.getYearMonthDay(new Date()));
        operateLogService.save(operateLog);
    }
}
